<template xmlns="http://www.w3.org/1999/html">
  <sea-data-table ref="tableObject" url="/kettle/variable/page">
    <!--表头-->
    <sea-table-header slot="header" disabled-form>
      <!--标题栏-->
      <sea-table-title slot="title" title="共享变量" subtitle="Kettle执行所需的参数，例如：数据日期、JDBC链接。"></sea-table-title>

      <!--按钮栏-->
      <template slot="buttons">
        <el-button plain size="small" title="新增" icon="fa fa-plus" @click="onAction('new')"></el-button>
      </template>
    </sea-table-header>

    <!-- 弹窗、抽屉 -->
    <panel slot="drawer" ref="panel"></panel>

    <!--表头-->
    <template slot="columns">
      <el-table-column property="name" label="字段名" width="180"></el-table-column>
      <el-table-column property="label" label="字段标签" width="180"></el-table-column>
      <el-table-column property="value" label="值" width="180"></el-table-column>
      <el-table-column property="desc" label="描述"></el-table-column>

      <!--操作栏-->
      <sea-table-actionbar width="180" :on-action="onAction" :buttons="buttons"></sea-table-actionbar>
    </template>
  </sea-data-table>
</template>

<script>
import Panel from "./panel";

export default {
    components: {
        Panel
    },
    methods: {
        /**
         * 操作成功回调
         */
        onSucceed: function () {
            this.$refs.tableObject.reload();
        },
        /**
         * 操作栏事件分发
         * @param evt 事件
         * @param row 行级对象
         * @param old 可供回滚的参数
         */
        onAction: function (evt, row, old) {
            this.$refs.panel.onAction(evt, row, old);
        }
    },
    data() {
        return {
            // 操作栏
            buttons: [
                {type: 'btn', evt: 'edit', label: '编辑', title: '编辑当前行'}
                , {type: 'btn', evt: 'remove', label: '删除', style: 'text-orange', title: '删除当前行'}
            ]
            // end--
        }
    }
}
</script>
